const nums = [1,2,3,4,5,6,7]
const k = 3
var rotate = function(nums, k) {
    const len=nums.length
    const arr1= nums.splice((len-k),k)
    const arr2=arr1.concat(nums)
    //const arr2=[...arr1,...nums]
    console.log(arr2)
    return arr2
};

console.log(rotate(nums,k))